import unittest
#====快排函数====
def insertion_sort(arr):
    for i in range(1, len(arr)):
        key = arr[i]
        j = i - 1
        while j >= 0 and arr[j] > key:
            arr[j + 1] = arr[j]
            j -= 1
        arr[j + 1] = key
    return arr
#=====数组赋值函数部分====
"""def shuru():
    n = int(input("请输入整数个数："))
    arr = []
    for i in range(n):
        num = int(input("请输入第{}个整数：".format(i + 1)))
        arr.append(num)
    return arr  """
#sorted_arr = insertion_sort(arr)
#print("排序后的整数为：", sorted_arr)
#====测试部分代码====
class Test(unittest.TestCase):
    def setUp(self):
        print("====执行测试用例====")

    # 执行测试用例编号1
    def test_sorting1(self):
        arr1 = []
        insertion_sort(arr1)
        self.assertEqual(arr1, [])
        print("测试用例编号1完成")

    # 执行测试用例编号2
    def test_sorting2(self):
        arr1 = [25, 11, 76, 99, 6]
        insertion_sort(arr1)
        self.assertEqual(arr1, [6, 11, 25, 76, 99])
        print("测试用例编号2完成")

    # 执行测试用例编号3
    def test_sorting3(self):
        arr1 = [1, 2, 3, 4, 5, 6]
        insertion_sort(arr1)
        self.assertEqual(arr1, [1, 2, 3, 4, 5, 6])
        print("测试用例编号3完成")

    # 执行测试用例编号4
    def test_sorting4(self):
        arr1 = [99, 88, 77, 33]
        insertion_sort(arr1)
        self.assertEqual(arr1, [33, 77, 88, 99])
        print("测试用例编号4完成")


    # 执行测试用例编号5
    def test_sorting5(self):
        arr1 = [32, 1, 3, 3, 3, 0]
        insertion_sort(arr1)
        self.assertEqual(arr1, [0, 1, 3, 3, 3, 32])
        print("测试用例编号5完成")


    # 执行测试用例编号6
    def test_sorting6(self):
        arr1 = [7, 75, 7, 9, 7, 1]
        insertion_sort(arr1)
        self.assertEqual(arr1, [1, 7, 7, 7, 9, 75])
        print("测试用例编号6完成")

    def tearDown(self):
        print("====测试用例完成====\n")

if __name__ == '__main__':
    unittest.main()












